package com.study.ai.springaidemo.controller;

import com.study.ai.springaidemo.service.ModelService;
import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloWordController {
    @Resource
    private ModelService modelService;

    @GetMapping("/chat")
    public String helloWord(@RequestParam(name = "modelName") String modelName,
                            @RequestParam(name = "question") String question) {
        ChatClient chatClient = modelService.getChatClient(modelName);
        String content = chatClient.prompt()
                .user(question)
                .call()
                .content();
        return content;
    }
}
